/**
* 左边菜单
*/
<template>
  <el-menu
    :collapse="collapsed"
    collapse-transition
    router
    :default-active="$route.path"
    unique-opened
    class="el-menu-left"
    background-color="rgb(2 70 162)"
    text-color="#fff"
    active-text-color="#ffd04b"
  >
    <div class="logobox">
      <img
        class="logoimg"
        src="../assets/img/logo.png"
        alt="奇特物联"
        @click="goHome"
      />
    </div>
    <el-submenu
      v-for="menu in allmenu"
      :key="menu.menuid"
      :index="menu.menuname"
    >
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item
          v-for="chmenu in menu.menus"
          :index="'/' + chmenu.url"
          :key="chmenu.menuid"
        >
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: "leftnav",
  data() {
    return {
      collapsed: false,
      allmenu: [
        {
          menuid: 1,
          icon: "li-icon-xiangmuguanli",
          menuname: "设备接入",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 101,
              icon: "li-icon-xiangmuguanli",
              menuname: "品类管理",
              hasThird: "N",
              url: "product/Categories",
              menus: null,
            },
            {
              menuid: 102,
              icon: "li-icon-xiangmuguanli",
              menuname: "产品管理",
              hasThird: "N",
              url: "product/Products",
              menus: null,
            },
            {
              menuid: 106,
              icon: "li-icon-xiangmuguanli",
              menuname: "设备列表",
              hasThird: "N",
              url: "device/Devices",
              menus: null,
            },
            {
              menuid: 107,
              icon: "li-icon-xiangmuguanli",
              menuname: "设备分组",
              hasThird: "N",
              url: "device/Groups",
              menus: null,
            },
            {
              menuid: 108,
              icon: "li-icon-xiangmuguanli",
              menuname: "虚拟设备",
              hasThird: "N",
              url: "device/VirtualDevices",
              menus: null,
            },
          ],
        },
        // {
        //   menuid: 2,
        //   icon: "li-icon-xiangmuguanli",
        //   menuname: "空间管理",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 201,
        //       icon: "li-icon-xiangmuguanli",
        //       menuname: "空间列表",
        //       hasThird: "N",
        //       url: "space/Spaces",
        //       menus: null,
        //     },
        //   ],
        // },
        {
          menuid: 3,
          icon: "li-icon-xiangmuguanli",
          menuname: "通讯组件管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 301,
              icon: "li-icon-xiangmuguanli",
              menuname: "设备消息转换器",
              hasThird: "N",
              url: "protocol/Convertors",
              menus: null,
            },
            {
              menuid: 302,
              icon: "li-icon-xiangmuguanli",
              menuname: "通讯组件管理",
              hasThird: "N",
              url: "protocol/Components",
              menus: null,
            },
          ],
        },
        // {
        //   menuid: 4,
        //   icon: "li-icon-xiangmuguanli",
        //   menuname: "App定制",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 4,
        //       icon: "li-icon-xiangmuguanli",
        //       menuname: "设备详情页定制",
        //       hasThird: "N",
        //       url: "app/AppDesign",
        //       menus: null,
        //     },
        //   ],
        // },
        {
          menuid: 5,
          icon: "li-icon-xiangmuguanli",
          menuname: "用户管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 501,
              icon: "li-icon-xiangmuguanli",
              menuname: "平台用户管理",
              hasThird: "N",
              url: "system/Users",
              menus: null,
            },
            {
              menuid: 502,
              icon: "li-icon-xiangmuguanli",
              menuname: "C端用户管理",
              hasThird: "N",
              url: "client/Users",
              menus: null,
            },
          ],
        },
        {
          menuid: 8,
          icon: "li-icon-xiangmuguanli",
          menuname: "规则引擎",
          hasThird: null,
          menus: [
            {
              menuid: 801,
              icon: "li-icon-xiangmuguanli",
              menuname: "规则管理",
              hasThird: "N",
              url: "rule/Rules",
              menus: null,
            },
            {
              menuid: 802,
              icon: "li-icon-xiangmuguanli",
              menuname: "定时任务",
              hasThird: "N",
              url: "rule/Tasks",
              menus: null,
            },
          ],
        },
        {
          menuid: 9,
          icon: "li-icon-xiangmuguanli",
          menuname: "告警中心",
          hasThird: null,
          menus: [
            {
              menuid: 901,
              icon: "li-icon-xiangmuguanli",
              menuname: "告警列表",
              hasThird: "N",
              url: "alarm/Alarms",
              menus: null,
            },
            {
              menuid: 902,
              icon: "li-icon-xiangmuguanli",
              menuname: "告警设置",
              hasThird: "N",
              url: "alarm/AlarmSettings",
              menus: null,
            },
          ],
        },
        {
          menuid: 7,
          icon: "li-icon-xiangmuguanli",
          menuname: "数据可见化",
          hasThird: null,
          menus: [
            {
              menuid: 701,
              icon: "li-icon-xiangmuguanli",
              menuname: "数据大屏",
              hasThird: "N",
              url: "dataView/Screen",
              menus: null,
            },
            {
              menuid: 702,
              icon: "li-icon-xiangmuguanli",
              menuname: "数据统计",
              hasThird: "N",
              url: "dataView/Statistics",
              menus: null,
            },
          ],
        },
      ],
    };
  },
  created() {
    this.$root.Bus.$on("toggle", (value) => {
      this.collapsed = !value;
    });
  },
  methods: {
    goHome() {
      this.$router.push({
        path: "/",
      });
    },
  },
};
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  text-align: center;
  background-color: #fff;
  margin: 5px auto;
  padding: 5px 0;
  border-radius: 100px;
  width: 100px;
  height: 100px;
  overflow: hidden;
}
.logoimg {
  height: 70px;
  cursor: pointer;
}
.el-menu-item.is-active {
  background-color: rgb(2 48 112) !important;
}
</style>
